package app.web.galgame.cgs;

import cn.lily.com.db.DBFactory;
import cn.lily.com.db.container.reader.DataTable;
import cn.lily.com.exception.YaconException;
import cn.lily.esb.enums.EnumManager;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.page.TPanel;
import cn.lily.web.widget.standard.TButton;
/**
 * 游戏采集Edit页面
 * @author JiaJ
 * @date 2018年5月31日
 *
 */
public class CGEdit extends BusinessPage {

	@Override
	public void page_onLoad() throws YaconException {
		
		TPanel galgameEditPanel = Panel("galgameEditPanel");
		galgameEditPanel.creatToolbar().setBarText("CG编辑");
		
		Form("galgameEditForm").setDictTable("LEO_CG_INFO");
		
		Form("galgameEditForm").createFormCell(Input("GAME_NAME"),6);
		
		//数据按钮添加
		TButton galAnalyseBtn = new TButton("galAnalyseBtn");
		galAnalyseBtn.setLabel("游戏分析");
		galAnalyseBtn.setViewClick("galAnalyseBtn_click");
		galAnalyseBtn.setState("danger");
		galAnalyseBtn.setViewType("label");
		Form("galgameEditForm").createFormCell(galAnalyseBtn,6);
		
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(Check("GAME_TYP").setEnumDetail(EnumManager.getTableEnum("GAME_TYP")).setInsertDefaultValue("ADV"));		
		Form("galgameEditForm").createFormCell(Radio("GAME_LANG").setInsertDefaultValue("02"));
		Form("galgameEditForm").createFormCell(Radio("GAME_VISUAL").setInsertDefaultValue("01"));
		Form("galgameEditForm").createFormRow();
		
		Drop("DISK_ID").setEnumDetail(EnumManager.getDBEnum("select DISK_ID,DISK_NAM from ${schema}.LEO_DISK_INFO where DISK_STATUS='1'"));
		Form("galgameEditForm").createFormCell(Drop("DISK_ID"),3);
		Form("galgameEditForm").createFormCell(Input("GAME_STORE_PATH"),6);
		Form("galgameEditForm").createFormCell(Input("GAME_SIZE"),3);
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(Input("GAME_PRO_TIME"));
		Form("galgameEditForm").createFormCell(Input("GAME_TAGS"));
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(Input("GAME_FACTORY"));
		Form("galgameEditForm").createFormCell(Input("GAME_FIRST"));
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(TextArea("GAME_NAME_PLUS").setAreaRow(3));
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(TextArea("GAME_INTRU").setAreaRow(12));
		Form("galgameEditForm").createFormRow();
		
		Form("galgameEditForm").createFormCell(TextArea("GEME_MEMO").setAreaRow(6));
		Form("galgameEditForm").createFormRow();
		
		galgameEditPanel.createPanelCell(Form("galgameEditForm"));
		galgameEditPanel.creatStatusBar().addElement(Button("save"));
		galgameEditPanel.getStatusBar().addElement(Button("exit"));
		getPage().addElement(galgameEditPanel);
		
	}
	
	public void gameSearch(){
		if(this.getViewTable().next()){
			String gameID = this.getViewTable().getString("gameID");
			
			String sqlString = "select RES_ID,GAME_ID,GAME_NAME,GAME_TYP,GAME_LANG,"
					+ "GAME_VISUAL,GAME_SIZE,GAME_SIZE_NUM,GAME_FACTORY,GAME_FIRST,"
					+ "GAME_INTRU,GEME_MEMO,GAME_NAME_PLUS,"
					+ "DISK_ID,GAME_STORE_PATH,GAME_TAGS,"
					+ "to_char(GAME_PRO_TIME,'yyyy-mm-dd') GAME_PRO_TIME,"
					+ "to_char(GAME_CRE_TIME,'yyyy-mm-dd') GAME_CRE_TIME from ${schema}.LEO_GALGAME_INFO_JPS where GAME_ID='"+gameID+"'";
			
			DataTable table = DBFactory.getActionDB().executeQueryTable(sqlString);
			this.setDataTable(table);
		}else{
			this.setSelfMessage("Error");
		}
	}

}
